Skip to content

stock price alerts#8

Open
Ayoubkhalil97 wants to merge 1 commit intoalexnaylor99:mainfrom
Ayoubkhalil97:stock-price-alert
Open

stock price alerts#8
Ayoubkhalil97 wants to merge 1 commit intoalexnaylor99:mainfrom
Ayoubkhalil97:stock-price-alert

Conversation

@Ayoubkhalil97
Copy link

No description provided.

@@ -0,0 +1,24 @@
import os
from time import sleep
from dotenv import load_dotenv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good practice to use environment variables!

SYMBOLS = ['TSLA', 'AAPL', 'MSFT', 'GOOGL', 'NKE']
BASE_IEX_URL = "https://cloud.iexapis.com/stable"

def main():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main function is concise, clean and has less code. That makes us easier to understand.


def fetch_price_and_avg(symbol, base_iex_url, iex_api_key):
endpoint = f"{base_iex_url}/stock/{symbol}/chart/5d?token={iex_api_key}"
try:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good use of error handling to detect errors!

@@ -0,0 +1,35 @@
import unittest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! well structured unit testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants